package com.hefu.virtuallife.ui.foods.adapter;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.dz.utlis.ClassTools;
import com.hefu.virtuallife.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * creat_user: zhengzaihong
 * Email:1096877329@qq.com
 * creat_date: 2018/6/24
 * creat_time: 11:35
 * describe 首页菜单
 **/
public class IndexMenueAdapter extends BaseAdapter {

    private String[] menuename = {"美食", "美团超市", "生鲜果蔬", "美团专访",
            "跑腿代购", "夜宵", "甜点饮品", "鸭脖卤味",
            "龙虾烧烤", "送药上门"};


    private int[] menueicon = {R.drawable.ic_ares, R.drawable.ic_ares,
            R.drawable.ic_ares, R.drawable.ic_ares,
            R.drawable.ic_ares, R.drawable.ic_ares,
            R.drawable.ic_ares, R.drawable.ic_ares,
            R.drawable.ic_ares, R.drawable.ic_ares,
    };

    private Context mContext;
    public IndexMenueAdapter(Context mContext){
        this.mContext=mContext;
    }


    @Override
    public int getCount() {
        return menuename.length;
    }

    @Override
    public Object getItem(int position) {
        return menuename[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (null == convertView) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_fragment_index_menue, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.tvMenue.setText(menuename[position]);
        viewHolder.ivMenueicon.setBackgroundResource(menueicon[position]);

        viewHolder.llitme.setOnClickListener(v -> {

        });
        return convertView;
    }


    class ViewHolder {
        @BindView(R.id.tv_menue)
        TextView tvMenue;
        @BindView(R.id.iv_menueicon)
        ImageView ivMenueicon;
        @BindView(R.id.ll_itme)
        LinearLayout llitme;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
